import request from '@/utils/request'
import { handleIdConflict, handleBatchIdConflict } from '@/utils/idConflictHandler'

// 查询产品入库记录行列表
export function listProductrecptline(query) {
  return request({
    url: '/mes/wm/productrecptline/list',
    method: 'get',
    params: query
  })
}

// 查询产品入库记录行详细
export function getProductrecptline(lineId) {
  return request({
    url: '/mes/wm/productrecptline/' + lineId,
    method: 'get'
  })
}

// 新增产品入库记录行（带ID冲突处理）
export function addProductrecptline(data, existingIds = []) {
  const apiCall = (requestData) => request({
    url: '/mes/wm/productrecptline',
    method: 'post',
    data: requestData
  });
  
  return handleIdConflict(apiCall, data, existingIds);
}

// 修改产品入库记录行（带ID冲突处理）
export function updateProductrecptline(data, existingIds = []) {
  const apiCall = (requestData) => request({
    url: '/mes/wm/productrecptline',
    method: 'put',
    data: requestData
  });
  
  return handleIdConflict(apiCall, data, existingIds);
}

// 删除产品入库记录行
export function delProductrecptline(lineId) {
  return request({
    url: '/mes/wm/productrecptline/' + lineId,
    method: 'delete'
  })
}

// 批量新增产品入库记录行（带ID冲突处理）
export function batchAddProductrecptline(dataList, existingIds = []) {
  const apiCall = (requestData) => request({
    url: '/mes/wm/productrecptline/batch',
    method: 'post',
    data: requestData
  });
  
  return handleBatchIdConflict(dataList, apiCall, existingIds);
}

// 批量更新产品入库记录行（带ID冲突处理）
export function batchUpdateProductrecptline(dataList, existingIds = []) {
  const apiCall = (requestData) => request({
    url: '/mes/wm/productrecptline/batch',
    method: 'put',
    data: requestData
  });
  
  return handleBatchIdConflict(dataList, apiCall, existingIds);
}
